# Contributor: Rob Blanckaert <basicer@gmail.com>
# Maintainer: Rob Blanckaert <basicer@gmail.com>
pkgname=luau
pkgver=0.607
pkgrel=0
pkgdesc="A fast, small, safe, gradually typed embeddable scripting language derived from Lua"
url="https://github.com/roblox/luau"
# arm: doesn't build, __deregister_frame
arch="all !armhf !armv7"
license="MIT"
makedepends="cmake linux-headers samurai"
source="
$pkgname-$pkgver.tar.gz::https://github.com/luau-lang/luau/archive/refs/tags/$pkgver.tar.gz
"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		$CMAKE_CROSSOPTS
	cmake --build build
}

check() {
	"$builddir"/build/Luau.UnitTest && "$builddir"/build/Luau.Conformance
}

package() {
	install -Dm755 build/luau "$pkgdir"/usr/bin/luau
	install -Dm755 build/luau-analyze "$pkgdir"/usr/bin/luau-analyze
	install -Dm755 build/luau-compile "$pkgdir"/usr/bin/luau-compile
}

sha512sums="
66025a2c88ea530f92d01fc3d7bea71d76847c615e150463d81b531a6ef6921b9898e25b62eeb4a2057e56ddd8d7b5b9aaaffca5c832d0c9eac9fa15712f7d19  luau-0.607.tar.gz
"
